<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="blog1.DBBean"%>
<%@ page import="blog1.UserBean"%>

<jsp:useBean id="myDBbean" class="blog1.DBBean"></jsp:useBean>

<jsp:useBean id="user" class="blog1.UserBean" scope="request"></jsp:useBean>
<jsp:setProperty name="user" property="*" />

<html>
  <head>
    <title>用户信息插入数据库</title>
  </head>
  
  <body>
    <h2>用户信息插入数据库</h2>
    <hr>
    <%
		//user对象中的userName和userPWD是通过自省完成赋值的
		request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
   
	    String info = request.getParameter("zhanghao");
	    String info1 = request.getParameter("mima");
	  	String ssex=new String(request.getParameter("xingbie").getBytes("ISO-8859-1"),"utf-8");
	  	String shobby="";
	  	shobby=new String(request.getParameter("aihao").getBytes("ISO-8859-1"),"utf-8");
	  	String semail="";
	  	semail=request.getParameter("youxiang");
	  	String age="";
	  	age=request.getParameter("nianling");
	  	String phone="";
	  	phone=request.getParameter("shoujihao");
	  	out.println(info);
	  	out.println(info1);
	  	String sql="INSERT INTO user(name,password,age,phoneNum,sex,hobby,email) VALUES('"+info+"','"+info1+"','"+age+"','"+phone+"',"+"'"+ssex+"','"+shobby+"','"+semail+"');";
	  	out.println(sql);
	  	myDBbean.update(sql);
		response.sendRedirect("Login.jsp");	
    %>
  </body>
</html>